package com.cloud.dong.service.impl;

import com.cloud.dong.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author DJ
 * @description 消息发送者
 * @date 2022/2/13 3:56 下午
 **/
@EnableBinding(Source.class)
public class IMessageProviderImpl implements IMessageProvider {

    /** 消息发送管道 */
    @Resource
    MessageChannel output;


    @Override
    public String send() {
        String messageValue = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(messageValue).build());
        System.out.println("****sendValue:" + messageValue);
        return null;
    }
}
